/**
	@file memtest.S
	@author Andrew D. Zonenberg
	@brief Does some dummy stuff with RAM
 */
 
.set noreorder					/*	Prevent any optimizations from reordering instructions!
									We want exe to exactly match source! */

/*
	Program entry point
 */
.section .startup.bootvec, "ax", @progbits 
.globl _start
_start:
	
	la			$t0, LEDBANKA		/*	LED array */
	li			$t1, 0x100			/*	Start of physical memory + 256 bytes.
										Note that the 0x00000000 address is mapped at the moment!
										A future version of the MMU will error on access to the first 256 addresses
										in order to allow easy catching of null-deref bugs. */
	
	li			$t2, 0xdeadbeef
	sw			$t2, 0($t1)			/*	store deadbeef to the first ram address */
	lw			$t3, 0($t1)			/*	t3 should be dead:beef now */
	
	srl			$t4, $t3, 16		/*	t4 = 0000:dead */
	xor			$t4, $t4, $t3		/*	t4 = dead:(dead^beef) = dead:6042 */
	andi		$t4, $t4, 0xffff	/*	t4 = 0000:6042 */
	srl			$t5, $t4, 8			/*	t5 = 0000:0060 */
	xor			$t5, $t5, $t4		/*	t5 = 0000:60(42^60) = 0000:6022 */
	andi		$t5, $t5, 0xff		/*	t5 = 0000:0022 */
	sw			$t5, 0($t0)			/*	write to LED bank: 0010:0010 */
	
	
.infloop:							/*	busy-wait forever */
	j			.infloop

